package cn.kgc.spring.entity.converter;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author: mosin
 * @version: v1.0  2022/6/30
 */
public class MyDateConverter implements Converter<String, Date> {

    @Override
    public Date convert(String source) { // 2020-12-17
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date parse = simpleDateFormat.parse(source);
            return  parse;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}
